<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.model.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" rev="stylesheet" href="../css/style.css"
	type="text/css" media="all" />

<script language="JavaScript" type="text/javascript">
	
</script>
<style type="text/css">
<!--
.atten {
	font-size: 12px;
	font-weight: normal;
	color: #F00;
}
-->
</style>
<script>
function save(){
	if(document.form.name.value == null || document.form.name.value == ""){
		alert("物品名称必须填写");
		return;
	}
	else if(document.form.amount.value == null || document.form.amount.value == ""){
		alert("库存必须填写");
		return;
	}
	else if(document.form.store.value == null || document.form.store.value == ""){
		alert("存放位置必须填写");
		return;
	}
	else if(document.form.unit.value == null || document.form.unit.value == ""){
		alert("计量单位必须填写");
		return;
	}
	else if(document.form.person.value == null || document.form.person.value == ""){
		alert("经手人必须填写");
		return;
	}
	else if(confirm("确认保存？")){
		document.form.submit();			
	}
}
</script>
</head>

<body class="ContentBody">
	<%
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");

		Connection con = DataBase.getConnection();

		//TODO: rewrite the sql clause
		PreparedStatement pstmtInfo = con
				.prepareStatement("SELECT * FROM item where iid=?");
		String iid = request.getParameter("iid");
		pstmtInfo.setString(1, iid);
		ResultSet rsInfo = pstmtInfo.executeQuery();
		if (!rsInfo.next()) {
	%>
	无效物品！请勿做非法输入！
	<%
		} else {
	%>
	<form action="ItemDeal?flag=edit" method="post" name="form">
		<div class="MainDiv">
			<table width="99%" border="0" cellpadding="0" cellspacing="0"
				class="CContent">
				<tr>
					<th class="tablestyle_title">物品信息修改</th>
				</tr>
				<tr>
					<td class="CPanel">
						<table border="0" cellpadding="0" cellspacing="0"
							style="width: 100%">
							<tr>
								<td align="left"><input type="button" name="Submit"
									value="保存" class="button" onclick="save()"/> <input type="button"
									name="Submit2" value="返回" class="button"
									onclick="window.history.go(-1);" /> <input type="hidden"
									name="iid" value="<%=iid%>" /></td>
							</tr>
							<tr>
								<td width="100%">
									<fieldset style="height: 100%">
										<legend>物品信息</legend>
										<table border="0" cellpadding="2" cellspacing="1"
											style="width: 100%">
											<tr>
												<td nowrap="nowrap" align="right" width="15%">物品名称:</td>
												<td width="35%"><input name='name' type="text"
													class="text" style="width: 154px"
													value="<%=rsInfo.getString("name")%>" /></td>
												<td width="16%" align="right" nowrap="nowrap">库存:</td>
												<td width="34%"><input class="text" name="amount"
													style="width: 154px"
													value="<%=rsInfo.getString("amount")%>" /></td>
											</tr>
											<tr>
												<td nowrap="nowrap" align="right">物品品牌:</td>
												<td><input class="text" name='brand'
													style="width: 154px" value="<%=rsInfo.getString("brand")%>" /></td>
												<td align="right">存放位置:</td>
												<td><input class="text" name='store'
													style="width: 154px" value="<%=rsInfo.getString("store")%>" /></td>
											</tr>

											<tr>
												<td nowrap="nowrap" align="right">计量单位:</td>
												<td><input class="text" name='unit'
													style="width: 154px" value="<%=rsInfo.getString("unit")%>" /></td>
												<td align="right">经手人:</td>
												<td><input class="text" name='person'
													style="width: 154px"
													value="<%=rsInfo.getString("person")%>" /></td>
											</tr>

											<tr>
												<td align="right">备注:</td>
												<td colspan="3"><textarea name="description" cols="100"
														rows="8"><%=rsInfo.getString("description")%></textarea></td>
											</tr>
										</table>
										<br />
									</fieldset>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center" height="50px"><input
						type="button" name="Submit" value="保存" class="button" onclick="save()"/> <input
						type="button" name="Submit2" value="返回" class="button"
						onclick="window.history.go(-1);" /></td>
				</tr>
			</table>

		</div>
	</form>
	<%
		}
		rsInfo.close();
		con.close();
	%>
</body>
</html>
